package simplefactory;

/**
 * @Author Fish Paradise
 * @Description
 * @Date 2019/1/30  11:26
 **/
public class FruitReflectFactory {
    Fruit fruit;
    public FruitReflectFactory(String name) {
        try {
             this.fruit = (Fruit) Class.forName("simplefactory."+name).getDeclaredConstructor().newInstance();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public Fruit getFruit(){
        return fruit;
    }
}
